import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'
const NameKey = 'Admin-Name'
const menuList = 'Meun-List'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token);
}

export function removeToken() {
  localStorage.removeItem(menuList);
  localStorage.removeItem(NameKey);
  return Cookies.remove(TokenKey)
}

export function MenuList(){
	this.menuList=menuList;
    return this;
}
export function UserName(){
  this.UserName=NameKey;
  return this;
}

MenuList.prototype={
  add:function(dataval){
      this.dataval=dataval || [];
     localStorage.setItem(this.menuList,JSON.stringify(this.dataval));
  },
  get:function(){
     return JSON.parse(localStorage.getItem(this.menuList));
  },
  remove:function(){
     localStorage.removeItem(this.menuList);
  },
  clear:function(){
     localStorage.clear();
  }
};

UserName.prototype={
  add:function(dataval){
      this.dataval=dataval || "";
     localStorage.setItem(this.UserName,JSON.stringify(this.dataval));
  },
  get:function(){
     return JSON.parse(localStorage.getItem(this.UserName));
  },
  remove:function(){
     localStorage.removeItem(this.UserName);
  },
  clear:function(){
     localStorage.clear();
  }
};
